import Ckphoto from './Ckphoto'
import * as actions from '../../redux/actions/CkphotoAction'
import * as globalActions from '../../redux/actions/GlobalAction'
import { StoreState } from '../../redux/Types'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'


export function mapStateToProps({ckphoto: { list, loading }, setting: { categorys, bands, venders } }: StoreState) {
  return {
    list,
    loading,
    categorys,
    bands,
    status,
    venders
  }
}
export function mapDispatchToProps(dispatch: Dispatch<actions.CkphotoAction | globalActions.GlobalAction>) {
  return {
    getList: (type: number, data: any) => {  
      dispatch(actions.recordType(type))
      dispatch(actions.getCkphotoList(data))
    },
    record: (record: any) => {
      const { id, no} = record
      dispatch(globalActions.recordSample({ id: no }))
      dispatch(globalActions.getSampleImgs({ sampleId: id }))
      dispatch(globalActions.getSampleChecked({ sampleId: id }))
    },
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(Ckphoto)